<template>
    <view class="content" v-if="isShow">
        <view class="box" v-for="(item, index) in list" :key="index" @click="toDetails(item)">
            <view class="top">
                <view class="item u-flex-1">
                    <view class="left">订单编号</view>
                    <view class="right">{{item.out_trade_no}}</view>
                </view>
                <view class="u-flex">
                    <!-- <view class="o-sta4" v-else>现场创建</view> -->
                    <view class="o-sta1" v-if="item.order_type == 1">零担</view>
                    <view class="o-sta2" v-if="item.order_type == 2">包车</view>
                </view>
            </view>
			
			<view class="top">
			    <view class="item u-flex-1">
			        <view class="left">下单日期</view>
			        <view class="right">{{item.create_time}}</view>
			    </view>
			    <view class="u-flex">
					<!-- create_type 1用户 4发货端 5卸货端 -->
			        <view class="o-sta3" v-if="item.create_type == 1">用户创建</view>
					<view class="o-sta4" v-if="item.create_type == 4">发货创建</view>
					<view class="o-sta4" v-if="item.create_type == 5">卸货创建</view>
			    </view>
			</view>
			
            <view class="item">
                <view class="left">发货方</view>
                <view class="right">{{item.shipper}}</view>
            </view>
            <view class="item">
                <view class="left">联系人</view>
                <view class="right">{{item.shipper_contact}}</view>
            </view>
            <view class="item">
                <view class="left">联系方式</view>
                <view class="right">{{item.shipper_phone}}</view>
            </view>
            <view class="item">
                <view class="left">装车地点</view>
                <view class="right">{{item.loading_site}}</view>
            </view>
            <view class="item">
                <view class="left">收货地址</view>
                <view class="right">{{item.address}}</view>
            </view>
            
            <view class="item">
                <view class="left">经营位置</view>
                <view class="right">{{item.position}}</view>
            </view>
            <view class="item">
                <view class="left">联系人</view>
                <view class="right">{{item.recipient_contact}}</view>
            </view>
            <view class="item">
                <view class="left">联系方式</view>
                <view class="right">{{item.recipient_phone}}</view>
            </view>
            <view class="item">
                <view class="left">发车时间</view>
                <view class="right">{{item.start_time}}</view>
            </view>
            <view class="item" v-if="item.carriage">
                <view class="left">车厢位置</view>
                <view class="right">{{item.carriage}}</view>
            </view>
            <view class="item" v-if="item.remark">
                <view class="left">备注</view>
                <view class="right">{{item.remark}}</view>
            </view>
        </view>
		
		<view style="height: 94rpx;padding-top: 30rpx;">
		    <u-loadmore :status="status" v-if="status != 'loadmore'" />
		</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                id: '',
				// type: '',
				status: 'loadmore', //是否显示没有更多了
				page: 1,
				list: [],
				isShow: false,
				title: '订单',
            };
        },
        onLoad(option) {
			console.log(option)
			if (option.type == 2) {
				this.title = '待装车订单'
			}
			if (option.type == 3) {
				this.title = '运输中订单'
			}
			if (option.type == 4) {
				this.title = '已到达订单'
			}
			uni.setNavigationBarTitle({
				title: this.title
			})
            this.id = option.id
			this.getList()
        },
		onReachBottom() {
			if(this.page == 1){return}
			this.getList()
		},
        methods: {
            toDetails(item) {
                this.$gTo(`/pages/send-records/ld-details?id=${item.id}`)
            },
			
			getList() {
				if (this.status == 'nomore') return;
				this.status = 'loading';
				this.$ajax('shipping_orders', {
					user_token: this.$getSync('userToken'),
					page: this.page,
					limit: 10,
			        car_id: this.id,//车辆运单id
				}).then(ret => {
					if (ret.success == 1000) {
						if (ret.detail && ret.detail.orders && ret.detail.orders.length > 0) {
							this.list = this.list.concat(ret.detail.orders);
							this.page++;
							this.status = 'loadmore'
						} else {
							this.status = 'nomore'
						}
						this.isShow = true
					} else {
						this.$toast(ret.msg);
					}
				});
			},
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #eef1f6;
    }
    
    .box{
        background-color: #fff;
        border-radius: 15rpx;
        padding: 40rpx 30rpx 30rpx;
        margin: 16rpx 20rpx 0;
    }
    .top{
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 10rpx;
    }
    .left{
        width: 190rpx;
        color: #656565;
    }
    .right{
        flex: 1;
        word-break: break-all;
        white-space: pre-line;
    }
    .o-sta{
        font-size: 24rpx;
        color: #ff602c;
        padding-bottom: 10rpx;
        padding-left: 10rpx;
    }
    .o-sta1{
        font-size: 24rpx;
        color: #ff602c;
        padding: 7rpx 15rpx;
        background-color: #fff1ec;
        border-radius: 10rpx;
        margin-left: 10rpx;
        margin-bottom: 10rpx;
    }
    .o-sta2{
        font-size: 24rpx;
        color: #0075ff;
        padding: 7rpx 15rpx;
        background-color: #ebf4fe;
        border-radius: 10rpx;
        margin-left: 10rpx;
        margin-bottom: 10rpx;
    }
    .o-sta3{
        font-size: 24rpx;
        color: #ff602c;
        padding: 7rpx 15rpx;
        border: 2rpx solid #ff602c;
        border-radius: 10rpx;
        margin-left: 10rpx;
        margin-bottom: 10rpx;
        box-sizing: border-box;
    }
    .o-sta4{
        font-size: 24rpx;
        color: #0075ff;
        padding: 7rpx 15rpx;
        border: 2rpx solid #0075ff;
        border-radius: 10rpx;
        margin-left: 10rpx;
        margin-bottom: 10rpx;
        box-sizing: border-box;
    }

</style>
